#include <algorithm>
#include <iostream>
using namespace std;

bool cmp(int a[],int b[])//升序greater<int>(),降序less<int>()
{
	if(a[0] != b[0]) return a[0] < b[0];
	if(a[1] != b[1]) return a[1] < b[1];
	if(a[2] != b[2]) return a[2] < b[2];
}

int main()
{
	int a[6] = {1, 2, 1, 1, 2, 3};		//储存re[i][0] 
	int b[6] = {4, 4, 3, 9, 5, 9};		//储存re[i][1] 
	int c[6] = {3, 7, 5, 4, 8, 6};		//储存re[i][2] 
	int i;
	
	int **re = new int*[6];		//动态创建二维数组 
	for (i = 0; i < 6; ++i)
	{
		re[i] = new int[3];
		re[i][0] = a[i];
		re[i][1] = b[i];
		re[i][2] = c[i];
	}
	
	sort(re, re + 6,cmp);		//排序后输出 
	for(i = 0; i < 6; ++i)
		cout << re[i][0] << ' ' << re[i][1] << ' ' << re[i][2] << endl;

	return 0;
}